/**
 * 快捷操作栏组件
 */
import React, { useState } from 'react';
import { Download, FileText, ExternalLink } from 'lucide-react';

interface QuickActionsProps {
  onExport?: () => void;
  onGenerateReport?: () => void;
  onNavigate?: (path: string) => void;
  exportFormats?: Array<'excel' | 'pdf' | 'word'>;
}

const QuickActions: React.FC<QuickActionsProps> = ({
  onExport,
  onGenerateReport,
  onNavigate,
  exportFormats = ['excel', 'pdf'],
}) => {
  const [showMenu, setShowMenu] = useState(false);

  return (
    <div className="flex items-center gap-2">
      {/* 导出按钮 */}
      {onExport && (
        <div className="relative">
          <button
            onClick={() => setShowMenu(!showMenu)}
            className="flex items-center gap-2 px-3 py-2 bg-blue-50 text-blue-600 rounded-lg hover:bg-blue-100 transition-colors text-sm font-medium"
          >
            <Download size={16} />
            导出
          </button>
          {showMenu && (
            <div className="absolute top-full right-0 mt-2 bg-white rounded-lg shadow-lg border border-gray-200 py-2 z-10 min-w-[120px]">
              {exportFormats.includes('excel') && (
                <button
                  onClick={() => {
                    onExport();
                    setShowMenu(false);
                  }}
                  className="w-full text-left px-4 py-2 text-sm hover:bg-gray-50"
                >
                  Excel
                </button>
              )}
              {exportFormats.includes('pdf') && (
                <button
                  onClick={() => {
                    onExport();
                    setShowMenu(false);
                  }}
                  className="w-full text-left px-4 py-2 text-sm hover:bg-gray-50"
                >
                  PDF
                </button>
              )}
              {exportFormats.includes('word') && (
                <button
                  onClick={() => {
                    onExport();
                    setShowMenu(false);
                  }}
                  className="w-full text-left px-4 py-2 text-sm hover:bg-gray-50"
                >
                  Word
                </button>
              )}
            </div>
          )}
        </div>
      )}

      {/* 生成报表 */}
      {onGenerateReport && (
        <button
          onClick={onGenerateReport}
          className="flex items-center gap-2 px-3 py-2 bg-green-50 text-green-600 rounded-lg hover:bg-green-100 transition-colors text-sm font-medium"
        >
          <FileText size={16} />
          生成报表
        </button>
      )}

      {/* 跳转业务页 */}
      {onNavigate && (
        <button
          onClick={() => onNavigate('/product')}
          className="flex items-center gap-2 px-3 py-2 bg-purple-50 text-purple-600 rounded-lg hover:bg-purple-100 transition-colors text-sm font-medium"
        >
          <ExternalLink size={16} />
          跳转业务页
        </button>
      )}
    </div>
  );
};

export default QuickActions;

